//
//  DYMoneyManageView.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/20.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYMoneyManageView.h"

@interface DYMoneyManageView ()

@property (nonatomic,strong)DYMoneyManageChildView *accountView;
@property (nonatomic,strong)DYMoneyManageChildView *freezeView;
@property (nonatomic,strong)UILabel *line1;
@property (nonatomic,strong)UILabel *line2;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UITextField *withdrawtextField;
@property (nonatomic,strong)UIButton *allButton;
@property (nonatomic,strong)UILabel *canWithdrawLabel;
@property (nonatomic,strong)UILabel *tipLabel;
@property (nonatomic,strong)UIButton *submitButton;


@end


@implementation DYMoneyManageView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}
-(void)initView
{
 
    self.backgroundColor=WhiteColor;
    
    self.accountView = ({
        DYMoneyManageChildView *view=[[DYMoneyManageChildView alloc]init];
        view;
    });
    
    
    self.freezeView = ({
        DYMoneyManageChildView *view=[[DYMoneyManageChildView alloc]init];
        [view.balanceButton setTitle:@"冻结金额" forState:UIControlStateNormal];
        [view.balanceButton setImage:IMG(@"ic_djye") forState:UIControlStateNormal];
        view;
    });
    
    self.line1=({
        UILabel *line=[UILabel xhq_lineLabel];
        line;
    });
    
    self.line2=({
        UILabel *line=[UILabel xhq_lineLabel];
        line;
    });
    
    
    self.titleLabel = ({
        UILabel *label=[Utils labelWithTitle:@"提现金额" titleFontSize:16 textColor:[UIColor xhq_content] backgroundColor:WhiteColor alignment:0];
        label;
    });
    
    self.withdrawtextField = ({
        UITextField *textField=[[UITextField alloc]init];
        [textField setNumbersKeyboard];
        textField.font=kFont(22);
        textField.textColor=[UIColor xhq_aTitle];
        textField.placeholder=@"请输入提现金额";
        textField.leftView=[Utils labelWithFrame:CGRectMake(0, 0, BILIWIDTH(20), BILIHEIGHT(40)) withTitle:@"¥" titleFontSize:22 textColor:[UIColor xhq_aTitle] backgroundColor:WhiteColor alignment:0];
        textField.leftViewMode=UITextFieldViewModeAlways;
        textField;
    });
    
    self.allButton = ({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor action:@selector(buttonClick:) target:self title:@"全部提现" image:nil font:14 textColor:[UIColor xhq_base]];
        button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        button;
    });
    
    self.canWithdrawLabel=({
        UILabel *label=[Utils labelWithTitle:@"可提现金额" titleFontSize:14 textColor:[UIColor xhq_content] backgroundColor:WhiteColor alignment:0];
        label;
    });
    
    self.tipLabel = ({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label;
    });
    
    self.submitButton = ({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:[UIColor xhq_base] action:@selector(buttonClick:) target:self title:@"确认提现" image:nil font:17 textColor:WhiteColor];
        [button xhq_cornerRadius:BILIHEIGHT(19)];
        button;
    });
    
    
    [self addSubview:self.accountView];
    [self addSubview:self.freezeView];
    [self addSubview:self.line1];
    [self addSubview:self.line2];
    [self addSubview:self.titleLabel];
    [self addSubview:self.withdrawtextField];
    [self addSubview:self.allButton];
    [self addSubview:self.canWithdrawLabel];
    [self addSubview:self.tipLabel];
    [self addSubview:self.submitButton];
    
    
    [self.accountView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(0);
        make.height.equalTo(BILIHEIGHT(77));
        make.width.equalTo(kScreenWidth/2-BILIWIDTH(10));
    }];
    
    [self.freezeView makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(0);
        make.top.height.width.equalTo(self.accountView);
    }];

    [self.line1 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(kScreenWidth/2);
        make.height.equalTo(BILIHEIGHT(30));
        make.centerY.equalTo(self.accountView);
        make.width.equalTo(BILIWIDTH(0.7));
    }];

    [self.line2 makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(0);
        make.top.equalTo(self.accountView.bottom);
        make.height.equalTo(BILIWIDTH(0.7));
    }];

    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(15));
        make.top.equalTo(self.line2.bottom).offset(BILIHEIGHT(12));
    }];
    
    [self.withdrawtextField makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.equalTo(self.titleLabel.bottom).offset(BILIHEIGHT(8));
        make.height.equalTo(BILIHEIGHT(40));
        make.width.equalTo(BILIWIDTH(240));
    }];

    [self.allButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(BILIWIDTH(-15));
        make.centerY.equalTo(self.withdrawtextField);
        make.size.equalTo(CGSizeMake(BILIHEIGHT(70), BILIHEIGHT(40)));
    }];
    
    [self.canWithdrawLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.equalTo(self.withdrawtextField.bottom).offset(BILIHEIGHT(8));
    }];

    [self.tipLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.canWithdrawLabel.bottom).offset(BILIHEIGHT(25));
        make.left.equalTo(self.titleLabel);
    }];

    [self.submitButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tipLabel.bottom).offset(BILIHEIGHT(150));
        make.centerX.equalTo(self);
        make.size.equalTo(CGSizeMake(BILIWIDTH(343), BILIHEIGHT(38)));
    }];
    
    
    self.tipLabel.text=@"提现说明：\n1.申请提现金额不低于100元/笔\n2.提现手续费为2元/笔";
    [self.tipLabel xhq_lineSpace:BILIHEIGHT(5)];
    
    self.accountView.moneyLabel.text=@"¥123.00";
    self.freezeView.moneyLabel.text=@"¥123.00";
}
-(void)buttonClick:(UIButton *)button
{
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end



@implementation DYMoneyManageChildView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    self.moneyLabel = ({
        UILabel *label=[Utils labelWithTitleFontSize:18 textColor:[UIColor xhq_aTitle] alignment:1];
        label;
    });
    
    self.balanceButton=({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:WhiteColor title:@"账户余额" image:@"ic_zhye" font:18];
        [button setTitleColor:[UIColor xhq_content] forState:UIControlStateNormal];
        button;
    });
    
    [self addSubview:self.moneyLabel];
    [self addSubview:self.balanceButton];
    
    [self.moneyLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(BILIHEIGHT(19));
    }];
    
    [self.balanceButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.moneyLabel.bottom).offset(BILIHEIGHT(BILIHEIGHT(8)));
    }];

    [self.balanceButton placeImageTitlePosition:ZYButtonImagePositionLeft space:BILIWIDTH(BILIWIDTH(5))];
}

@end
